<?php

namespace App\Http\Controllers;

use App\Repositories\DeviceRepository;
use App\Repositories\ScenicRepository;
use App\Setting;
use Illuminate\Http\Request;

class ScenicController extends Controller
{
    protected $scenicRepository;

    public function __construct()
    {
       $this->scenicRepository= new ScenicRepository();
    }

    public function shake(){
        return view('web.scenic.shake');
    }
    public function index(){
        //自动试听
        $sceneId=Setting::getConfig('sceneId');
        return view('web.scenic.index',compact('sceneId'));
    }
    public function shaketest(){
        $sceneId=Setting::getConfig('sceneId');
        return redirect()->route('scene',['id'=>$sceneId]);
    }
    public function detail($id){
       $detail= $this->scenicRepository->getDetail($id);
       $isBuy=$this->scenicRepository->checkScenicAuth($id);
       return view('web.scenic.detail',compact('detail','isBuy'));
    }
    public function ajaxScenic(Request $request){
        $deviceRepository=new DeviceRepository();

        return  $deviceRepository->deviceByScenic(['major'=>$request->major,'minor'=>$request->minor]);
    }
}
